package com.example.design.bilibili.memento;

/**
 * 备忘录模式
 */
public class Client {

    public static void main(String[] args) {

        Originator originator = new Originator();
        CareTaker careTaker = new CareTaker();

        originator.setState("状态#1 攻击力 100");
        //保存了当前状态
        careTaker.add(originator.saveStateMemento());

        originator.setState("状态#2 攻击力 80");
        careTaker.add(originator.saveStateMemento());

        originator.setState("状态#3 攻击力 50");
        careTaker.add(originator.saveStateMemento());

        System.out.println("当前的状态是="+originator.getState());

        //希望得到状态1，奖Orginator的状态恢复到1
        originator.getStateFromMemento(careTaker.get(0));
        System.out.println("恢复到状态1，当前状态是="+originator.getState());
    }
}
